<?php
namespace app\admin\validate;

use think\Validate;

class MachineVersionValidate extends Validate
{
    protected $rule = [
        'version_name' => 'require|checkVersion',
        'remark' => 'require|max:200',
        'file' => 'require|file|fileSize:204857600|fileExt:zip',
    ];

    //验证版本
    protected function checkVersion($value)
    {
        $preg = '/^(\d){1,2}\.(\d){1,2}$/';
        $match = preg_match($preg, $value);
        if (!$match) {
            return '版本格式错误，例：最小0.00, 最大99.99';
        }

        return true;
    }
}
